package file;

import java.io.File;
import java.io.IOException;

/**
 * 删除一个目录(文件夹)
 */
public class DeleteDirDemo {
    public static void main(String[] args) throws IOException {

        File dir = new File("demo");
        dir.createNewFile();
        System.out.println(dir.list());



    }
    public static void delete(File file){
        if(file.isDirectory()){
            File[] subs = file.listFiles();
            for (int i = 0; i < subs.length; i++) {
                File sub = subs[i];
                delete(sub);//
            }
        }

        file.delete();
    }
}
